package com.addplus.townmall.server.api.mapper.town;

import com.addplus.townmall.server.api.model.town.GiftCardCommentRecord;
import com.addplus.townmall.server.api.model.town.expand.GiftCardCommentRecordExpand;
import com.addplus.townmall.server.api.utils.BaseAddMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 礼品卡会员评价详细表 Mapper 接口
 * </p>
 *
 * @author zhangjiehang
 * @since 2018-09-17
 */
public interface GiftCardCommentRecordMapper extends BaseAddMapper<GiftCardCommentRecord> {

    @Select("SELECT\n" +
            "\tgccr.*,\n" +
            "\tgc.gift_card_name AS shop_name,\n" +
            "\tgc.gift_card_seal_img AS shop_seal_img\n" +
            "FROM\n" +
            "\tgift_card_comment_record gccr\n" +
            "\tLEFT JOIN gift_card gc ON gc.id = gccr.gift_card_id \n" +
            "WHERE\n" +
            "\tgccr.member_id = #{memberId} \n" +
            "\tAND gccr.order_id = #{orderId} \n" +
            "\tAND gccr.is_deleted = 0")
    public List<GiftCardCommentRecordExpand> getCommentByOrderIdAndMemberId(@Param("memberId") Integer memberId, @Param("orderId") Integer orderId);

}
